<?php
/**
 * 程序二接口
 * @Description: 计算数据并输出表格
 * @param categoryFrom 类目表单数据 format:json
 * @param conditionFrom 数据筛选表单数据 format:json
 * @param computeFrom 计算表单数据 format:json
 * @param isOutSumColumn 是否输出所有顶部算法的值和权重的总和
 * @return \Excel
 */
 
require './src/Spout/Autoloader/autoload.php';
require './init.php';
require './Sheet.php';

use Box\Spout\Writer\WriterFactory;
use Box\Spout\Reader\ReaderFactory;
use Box\Spout\Common\Type;
use app\Sheet;

// 接收传值
$categoryColumn = $_POST['categoryColumn'];
$customCategorys = json_decode($_POST['categoryFrom'],true);
$conditions = json_decode($_POST['conditionFrom'],true);
$outColumns = json_decode($_POST['computeFrom'],true);
$secondComputeParams = json_decode($_POST['secondComputeParams'],true);
$isOutSumColumn = $_POST['isOutSumColumn'];
$inputFilePath = './upload/excel2.xlsx';
$outputFilePath = './download/程序二_' . date('Y_m_d_H_i_s') . '.xlsx';
$objReader = ReaderFactory::create(Type::XLSX);
$objWriter = WriterFactory::create(Type::XLSX);

$sheetModel = new Sheet;
$sheetModel->filterAndOutput($categoryColumn,
	$customCategorys,$conditions,$outColumns,
	$isOutSumColumn,$inputFilePath,$outputFilePath,
	$objReader,$objWriter,$secondComputeParams);

echo json_encode([
	'url'	=>		DOMAIN_NAME . $outputFilePath,
	'code'	=>		'20000'
]);




		
		
		